# Maintainer: Thore Bödecker <foxxx0@archlinux.org>
# Contributor: Lukas Zimmermann <luk.zim91 at gmail dot com> 
# Contributor: Kelsey Maes <kelseymaes at outlook dot com>

pkgname=python-adal
_pkgbase='azure-activedirectory-library-for-python'
pkgver=1.2.7
pkgrel=4
pkgdesc='ADAL for Python'
arch=('any')
url="https://github.com/AzureAD/${_pkgbase}"
license=('MIT')
depends=('python-cryptography' 'python-dateutil' 'python-pyjwt' 'python-requests')
makedepends=('fakeroot' 'python-setuptools')
checkdepends=('python-httpretty')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/AzureAD/${_pkgbase}/archive/${pkgver}.tar.gz"
        'fix-broken-mex-test.patch')
sha256sums=('26ccdb8981bb804ba4e64fa26693ae647642b6a54335ce2440edc6681119d563'
            '29a9354028a9420ba883cb494688a0ecbf238d8e46fc011c4a309515a1444faa')

prepare() {
  cd "${srcdir}/${_pkgbase}-${pkgver}"
  patch -p1 -N -i "${srcdir}/fix-broken-mex-test.patch"
}

build() {
  cd "${srcdir}/${_pkgbase}-${pkgver}"
  python setup.py build
}

check() {
  cd "${srcdir}/${_pkgbase}-${pkgver}"
  python -m unittest discover -s tests
}

package() {
  cd "${srcdir}/${_pkgbase}-${pkgver}"
  python setup.py install --root="${pkgdir}" --optimize=1
  install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
